<?php
namespace Pw\MainBundle\Classes;
class Tag
{
	protected $name;
	protected $allowedParams;
	protected $parity;
	protected $replaceOpen;
	protected $replaceClose;
	protected $params;
	
	public function __construct($name, $rOpen, $rClose, $parity = true, $allowedParams = array()){
		$this->name = $name;
		$this->replaceOpen = $rOpen;
		$this->replaceClose = $rClose;
		$this->parity = $parity;
		$this->allowedParams = $allowedParams;
	}
	
	public function getName() {
		return $this->name;
	}
	public function getRepalceOpen() {
		return $this->replaceOpen;
	}
	public function getRepalceClose() {
		return $this->replaceClose;
	}
	
	public function isParamAllowed($param, $value){
		if (isset($this->allowedParams[$param]) && in_array($value, $this->allowedParams[$param])) {
			return true;
		}
		return false;
	}
	
	public function isPaired(){
		return $this->parity;
	}
	
	public function addParams($params){
		if (is_array($params)) {
			foreach ($params as $name => $value) {
				if ($this->isParamAllowed($name, $value)) {
					$this->params[$name] = $value;
				}
			}
		}
	}	
}
